package pers.cz.job;

import pers.cz.date.DateUtils;
import pers.cz.mapper.AutoCollectTestCaseMapper;
import pers.cz.model.AutoCollectTestCaseExample;
import pers.cz.quartz.job.AbstractQuartzJob;
import pers.cz.spring.SpringContextUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.Date;
import java.util.Map;

/**
 * 定时任务清除前两天录制的报文
 * @program: PostGirl-panent
 * @description: ClearCollectionInterfaceJob
 * @author: Cheng Zhi
 * @create: 2022-02-09 19:03
 **/
public class ClearCollectionInterfaceJob extends AbstractQuartzJob {

    @Override
    public void doJob(JobExecutionContext var1, Map params) throws JobExecutionException {

        // 获取当前时间的前二天
        Date date = DateUtils.getBeforeDate(2);
        // 删除大于指定日期的数据
        AutoCollectTestCaseExample example = new AutoCollectTestCaseExample();
        AutoCollectTestCaseExample.Criteria criteria = example.createCriteria();
        criteria.andSyncTimeLessThan(date);
        SpringContextUtil.getBean(AutoCollectTestCaseMapper.class).deleteByExample(example);

    }
}
